package cn.cnic.security.nssap.stearm.etl.handler;

import cn.cnic.security.nssap.stearm.etl.dao.flowDao;
import cn.cnic.security.nssap.stearm.etl.entity.FlowEntity;
import com.alibaba.fastjson.JSON;

import java.sql.PreparedStatement;
import java.util.List;

/**
 * 流量传感器
 * Created by xiaojianping
 * Data:2021/6/10
 * Time:16:09
 */
public class flowAlarmHandler implements AlarmHandler<FlowEntity> {

  public FlowEntity process(String jsonOriginal){
//    JSONObject jb=JSON.parseObject(jsonOriginal);
//    String first_access_time=jb.getString("first_access_time");
//    String hazard_level=jb.getString("hazard_level");
//    String white_id=jb.getString("white_id");
//    String type_chain=jb.getString("type_chain");
//    String attck=jb.getString("attck");
//    String repeat_count=jb.getString("repeat_count");
//    String uri=jb.getString("uri");
//    String x_forwarded_for=jb.getString("x_forwarded_for");
//    String rsp_status=jb.getString("rsp_status");
//    String alarm_source=jb.getString("alarm_source");
//    String alarm_sip=jb.getString("alarm_sip");
//    String threat_name=jb.getString("threat_name");
//    String group_id=jb.getString("group_id");
//    String attack_org=jb.getString("attack_org");
//    String attack_sip=jb.getString("attack_sip");
//    String host=jb.getString("host");
//    String ioc=jb.getString("ioc");
//    String access_time=jb.getString("access_time");
//    String attack_chain=jb.getString("attack_chain");
      FlowEntity list=JSON.parseObject(jsonOriginal,FlowEntity.class);
      return  list;

  }

    @Override
    public int insertDB(FlowEntity entity) {
      flowDao sa=new flowDao();
      int count=sa.add(entity);
      return count;
    }

    @Override
    public void batchInsert(List<FlowEntity> list) {

    }

  @Override
  public void prepareStatementBatch(String json, PreparedStatement preparedStatement, String sql) {

  }
}
